﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 了解委托
{
    public delegate void sendMessageDelegate(string msg);
    public partial class Form2 : Form
    {
        //public event sendMessageDelegate sendEvent;
        public Form2()
        {
            InitializeComponent();
            Form1 f1 = new Form1();
            f1.sendEvent += recv;
            f1.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //sendEvent("第二个窗体发过来的消息! ");
        }

        void recv(string s)
        {
            MessageBox.Show("第二个窗体接受到消息!" + s);
        }
    }
}
